package com.mzy.basics.utils.Date;

import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author Ives
 * * @date 2021/12/27
 */
@Slf4j
public class FormatDate {

  /**
   *时间格式转化为字符串格式
   */

  public static Date formatDate(Date date) {

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");

    try {
      Date parse = sdf.parse(sdf.format(date));
      return parse;
    } catch (ParseException e) {
      log.info("时间格式转化为字符串失败: {}",e);
    }
    return  null;
  }
}
